class Scope {
  constructor(options) {
    this.parent = options?.parent || null
    this.names = options?.params || []

  }
  add(name) {
    this.names.push(name)
  }
  cantains(name) {
    return !!this.findDefiningScope(name)
  }
  findDefiningScope(name) {
    if (this.names.includes(name)) {
      return this
    }
    if (this.parent) {
      return this.parent.findDefiningScope(name)
    }
    return null

  }
}

module.exports = Scope
